<template>
  <div class="page-container" v-loading="loading">
    <div class="page-content">
      <div class="panel-container">
        <div class="panel-content">
          <div class="panel-title">中废通资讯详情</div>
          <div class="value tinymce-content" v-if="info">
            <div class="title">{{ info.Title }}</div>
            <div class="line info">
              <div class="info-item">作者：{{ info.AddAdmin }}</div>
              <div class="info-item">时间：{{ info.AddTime }}</div>
              <div class="info-item">浏览：{{ info.views }}</div>
            </div>
            <div class="desc" v-html="toHtml(info.Content)"></div>
          </div>
          <el-empty v-else></el-empty>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'InfomationDetail',
  components: {},
  data() {
    return {
      loading: false,
      info: null,
    }
  },
  mounted() {
    this.getData()
  },
  destroyed() {},
  methods: {
    // 获取数据列表
    getData() {
      const { id } = this.$route.query
      let storage = localStorage.getItem('InfomationDetail')
      if (storage) {
        let info = JSON.parse(storage)
        if (String(info.ID) === String(id)) {
          this.info = info
        }
      }
    },
    toHtml(val) {
      var rep = function (re, str) {
        val = val.replace(re, str)
      }
      rep(/\/kindeditor\//gi, 'https://kehu2.feijiu.net:82/kindeditor/')
      rep(/&nbsp;|\u00a0/gi, ' ')
      rep(/&quot;/gi, '"')
      rep(/&lt;/gi, '<')
      rep(/&gt;/gi, '>')
      rep(/&amp;/gi, '&')
      return val
    },
  },
}
</script>

<style scoped lang="scss">
.panel-content {
  min-height: 600px;
}
.title {
  text-align: center;
  font-size: 16px;
  color: #333333;
  font-weight: bold;
  line-height: 40px;
  margin-top: 20px;
}
.info {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 10px;
  color: #666666;
  .info-item {
    margin: 0 10px;
  }
}
.desc {
  margin-top: 20px;
  text-align: left;
  line-height: 2;
  color: #333333;
}
</style>
